/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "deposito", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Deposito.findAll", query = "SELECT d FROM Deposito d"),
    @NamedQuery(name = "Deposito.findByIddeposito", query = "SELECT d FROM Deposito d WHERE d.depositoPK.iddeposito = :iddeposito"),
    @NamedQuery(name = "Deposito.findByIdsucursal", query = "SELECT d FROM Deposito d WHERE d.depositoPK.idsucursal = :idsucursal"),
    @NamedQuery(name = "Deposito.findByDepDescrip", query = "SELECT d FROM Deposito d WHERE d.depDescrip = :depDescrip")})
public class Deposito implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DepositoPK depositoPK;
    @Column(name = "dep_descrip")
    private Integer depDescrip;
    @JoinColumn(name = "idsucursal", referencedColumnName = "idsucursal", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Sucursal sucursal;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "deposito")
    private Collection<Seccion> seccionCollection;

    public Deposito() {
    }

    public Deposito(DepositoPK depositoPK) {
        this.depositoPK = depositoPK;
    }

    public Deposito(int iddeposito, int idsucursal) {
        this.depositoPK = new DepositoPK(iddeposito, idsucursal);
    }

    public DepositoPK getDepositoPK() {
        return depositoPK;
    }

    public void setDepositoPK(DepositoPK depositoPK) {
        this.depositoPK = depositoPK;
    }

    public Integer getDepDescrip() {
        return depDescrip;
    }

    public void setDepDescrip(Integer depDescrip) {
        this.depDescrip = depDescrip;
    }

    public Sucursal getSucursal() {
        return sucursal;
    }

    public void setSucursal(Sucursal sucursal) {
        this.sucursal = sucursal;
    }

    @XmlTransient
    public Collection<Seccion> getSeccionCollection() {
        return seccionCollection;
    }

    public void setSeccionCollection(Collection<Seccion> seccionCollection) {
        this.seccionCollection = seccionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (depositoPK != null ? depositoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Deposito)) {
            return false;
        }
        Deposito other = (Deposito) object;
        if ((this.depositoPK == null && other.depositoPK != null) || (this.depositoPK != null && !this.depositoPK.equals(other.depositoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.Deposito[ depositoPK=" + depositoPK + " ]";
    }
    
}
